<html>
 <head>
  <link href="./leetcode-problem.css" rel="stylesheet" type="text/css">
 </head>
 <body>
  <div class="question_difficulty">
   难度：Hard
  </div>
  <div>
   <h1 class="question_title">
    884. K-Similar Strings
   </h1>
   <p>
    Strings&nbsp;
    <code>
     A
    </code>
    and
    <code>
     B
    </code>
    are
    <code>
     K
    </code>
    -similar (for some non-negative integer
    <code>
     K
    </code>
    ) if we can swap the positions of two letters in
    <code>
     A
    </code>
    exactly
    <code>
     K
    </code>
    &nbsp;times so that the resulting string equals
    <code>
     B
    </code>
    .
   </p>
   <p>
    Given two anagrams
    <code>
     A
    </code>
    and
    <code>
     B
    </code>
    , return the smallest
    <code>
     K
    </code>
    &nbsp;for which
    <code>
     A
    </code>
    and
    <code>
     B
    </code>
    are
    <code>
     K
    </code>
    -similar.
   </p>
   <p>
    <strong>
     Example 1:
    </strong>
   </p>
   <pre>
<strong>Input: </strong>A = <span id="example-input-1-1">"ab"</span>, B = <span id="example-input-1-2">"ba"</span>
<strong>Output: </strong><span id="example-output-1">1</span>
</pre>
   <div>
    <p>
     <strong>
      Example 2:
     </strong>
    </p>
    <pre>
<strong>Input: </strong>A = <span id="example-input-2-1">"abc"</span>, B = <span id="example-input-2-2">"bca"</span>
<strong>Output: </strong><span id="example-output-2">2</span>
</pre>
    <div>
     <p>
      <strong>
       Example 3:
      </strong>
     </p>
     <pre>
<strong>Input: </strong>A = <span id="example-input-3-1">"abac"</span>, B = <span id="example-input-3-2">"baca"</span>
<strong>Output: </strong><span id="example-output-3">2</span>
</pre>
     <div>
      <p>
       <strong>
        Example 4:
       </strong>
      </p>
      <pre>
<strong>Input: </strong>A = <span id="example-input-4-1">"aabc"</span>, B = <span id="example-input-4-2">"abca"</span>
<strong>Output: </strong><span id="example-output-4">2</span></pre>
     </div>
    </div>
   </div>
   <p>
    <strong>
     Note:
    </strong>
   </p>
   <ol>
    <li>
     <code>
      1 &lt;= A.length == B.length &lt;= 20
     </code>
    </li>
    <li>
     <code>
      A
     </code>
     and
     <code>
      B
     </code>
     contain only lowercase letters from the set
     <code>
      {'a', 'b', 'c', 'd', 'e', 'f'}
     </code>
    </li>
   </ol>
  </div>
  <div>
   <h1 class="question_title">
    884. 相似度为 K 的字符串
   </h1>
   <p>
    如果可以通过将
    <code>
     A
    </code>
    中的两个小写字母精确地交换位置
    <code>
     K
    </code>
    次得到与
    <code>
     B
    </code>
    相等的字符串，我们称字符串&nbsp;
    <code>
     A
    </code>
    &nbsp;和&nbsp;
    <code>
     B
    </code>
    &nbsp;的相似度为
    <code>
     K
    </code>
    （
    <code>
     K
    </code>
    &nbsp;为非负整数）。
   </p>
   <p>
    给定两个字母异位词&nbsp;
    <code>
     A
    </code>
    &nbsp;和&nbsp;
    <code>
     B
    </code>
    &nbsp;，返回
    <code>
     A
    </code>
    和
    <code>
     B
    </code>
    &nbsp;的相似度
    <code>
     K
    </code>
    的最小值。
   </p>
   <p>
    &nbsp;
   </p>
   <p>
    <strong>
     示例 1：
    </strong>
   </p>
   <pre><strong>输入：</strong>A = "ab", B = "ba"
<strong>输出：</strong>1
</pre>
   <p>
    <strong>
     示例 2：
    </strong>
   </p>
   <pre><strong>输入：</strong>A = "abc", B = "bca"
<strong>输出：</strong>2
</pre>
   <p>
    <strong>
     示例 3：
    </strong>
   </p>
   <pre><strong>输入：</strong>A = "abac", B = "baca"
<strong>输出：</strong>2
</pre>
   <p>
    <strong>
     示例 4：
    </strong>
   </p>
   <pre><strong>输入：</strong>A = "aabc", B = "abca"
<strong>输出：</strong>2</pre>
   <p>
    &nbsp;
   </p>
   <p>
    <strong>
     提示：
    </strong>
   </p>
   <ol>
    <li>
     <code>
      1 &lt;= A.length == B.length &lt;= 20
     </code>
    </li>
    <li>
     <code>
      A
     </code>
     &nbsp;和&nbsp;
     <code>
      B
     </code>
     &nbsp;只包含集合&nbsp;
     <code>
      {'a', 'b', 'c', 'd', 'e', 'f'}
     </code>
     &nbsp;中的小写字母。
    </li>
   </ol>
  </div>
 </body>
</html>